#include "StdAfx.h"

#include "ResourceUtils.h"
#include "FormatUtils.h"
#include "..\..\..\Common\IntToString.h"
#include "OverwriteDialogRes.h"
/*
static CStringW ConvertSizeToStringShort(UInt64 value)
{
  wchar_t s[32];
  wchar_t c, c2 = L'B';
  if (value < (UInt64)10000)
  {
    c = L'B';
    c2 = L'\0';
  }
  else if (value < ((UInt64)10000 << 10))
  {
    value >>= 10;
    c = L'K';
  }
  else if (value < ((UInt64)10000 << 20))
  {
    value >>= 20;
    c = L'M';
  }
  else
  {
    value >>= 30;
    c = L'G';
  }
  ConvertUInt64ToString(value, s);
  int p = MyStringLen(s);
  s[p++] = L' ';
  s[p++] = c;
  s[p++] = c2;
  s[p++] = L'\0';
  return s;
}
*/

static CStringW AddSizeValue(UInt64 size)
{
	return MyFormatNew(IDS_FILE_SIZE, 0x02000982, ConvertSizeToString(size));
}


CStringW ConvertSizeToString(UInt64 value)
{
	wchar_t s[32];
	ConvertUInt64ToString(value, s);
	int i = MyStringLen(s);
	int pos = sizeof(s) / sizeof(s[0]);
	s[--pos] = L'\0';
	while (i > 3)
	{
		s[--pos] = s[--i];
		s[--pos] = s[--i];
		s[--pos] = s[--i];
		s[--pos] = L' ';
	}
	while (i > 0)
		s[--pos] = s[--i];
	return s + pos;
}

void AddValuePair2(UINT resourceID, UInt32 langID, UInt64 num, UInt64 size, CStringW &s)
{
	if (num == 0)
		return;
	s += LangString(resourceID, langID);
	s += L" ";
	s += ConvertSizeToString(num);

	if (size != (UInt64)(Int64)-1)
	{
		s += L"    ( ";
		s += AddSizeValue(size);
		s += L" )";
	}
	s += L"\n";
}


